package net.com.hydroPK.net.packethandler;

import net.com.hydroPK.model.Player;
import net.com.hydroPK.model.combat.PlayerMagic;
import net.com.hydroPK.model.misc.PlayerMethods;
import net.com.hydroPK.npcs.NPC;
import net.com.hydroPK.Engine;

/**
 * File created by: Joshua
 * Created on 17/2/2010 at 23:40
 */
public class MagicOnNpc {

    public Player p;

    public MagicOnNpc(Player p) {
        this.p = p;

        int npcSlot = p.stream.readSignedWordA();
        p.clickId = p.stream.readUnsignedWord();
        int interfaceId = p.stream.readUnsignedWord();

        NPC n = Engine.npcs[npcSlot];
        p.clickX = n.absX;
        p.clickY = n.absY;
        Engine.playerMovement.resetWalkingQueue(p);

        if (n.maxHP == 0 || n.currentHP == 0) {
            return;
        }
        if (n.isDead || p.isDead) {
            return;
        }
        // Magic on npc shit here
        if (p.restrictedAttack(npcSlot)) {
            return;
        }
        p.playerMagic.combatMagicNpc(n, interfaceId, p.clickId);
    }
}
